#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "ValueSpecification.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class ValueSpecification;

/// <summary>
/// Expression
/// An Expression represents a node in an expression tree, which may be non-terminal
/// or terminal. It defines a symbol, and has a possibly empty sequence of operands
/// that are ValueSpecifications. It denotes a (possibly empty) set of values when
/// evaluated in a context.
/// </summary>
class UMLMODEL_EXPORT Expression : public ValueSpecification {

public: // Constructors and destructors
    explicit Expression(const QString& umlType="uml::Expression");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// operands getter
    /// Specifies a sequence of operand ValueSpecifications.
    /// </summary>
    vector<shared_ptr<ValueSpecification>>& operands();

    /// <summary>
    /// symbol getter
    /// The symbol associated with this node in the expression tree.
    /// </summary>
    QString symbol() const;

    /// <summary>
    /// symbol setter
    /// The symbol associated with this node in the expression tree.
    /// </summary>
    void setSymbol(const QString& value);

private: // Fields
    /// <summary>
    /// operands
    /// Specifies a sequence of operand ValueSpecifications.
    /// </summary>
    vector<shared_ptr<ValueSpecification>> operands_;

    /// <summary>
    /// symbol
    /// The symbol associated with this node in the expression tree.
    /// </summary>
    const static QString symbol_default_;
    QString symbol_= symbol_default_;

};

} // namespace uml
